package lab02.Test11;

public class   Rectangle implements Printx {
    //Printx接口，有求面积、求周长的方法，printMyWay()方法要能显示矩形的边长、面积和周长。
    double a;
    double b;
    private double perimeter;
    private double area;

    public  Rectangle(){}

    public Rectangle(double a,double b){

        this.a=a;
        this.b=b;
    }

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    private double getPerimeter() {
        perimeter=2*(a+b);
        return perimeter;
    }

    public void setPerimeter(double perimeter) {
        this.perimeter =  perimeter;
    }

    private double  getArea() {
        area=a*b;
        return area;
    }

    public void setArea(double area) {
        this.area = area;
    }



    @Override
    public void printMyWay() {
        System.out.println("边长："+a+"\t"+b+"\n"+"周长："+getPerimeter()+"\n"+"面积："+getArea());
    }


}
